﻿//Write a program that calculates the greatest common divisor (GCD) of given two numbers. 
//Use the Euclidean algorithm (find it in Internet).

using System;

class CalcGCD
{
    static void Main()
    {
        Console.Write("Enter first number: ");
        decimal a = decimal.Parse(Console.ReadLine());
        Console.Write("Enter second number: ");
        decimal b = decimal.Parse(Console.ReadLine());

        Console.Write("GCD({0}, {1}) = ", a, b);
        if (a != 0 && b != 0)
        {
            while (a != b)
            {
                if (a > b)
                {
                    a = a - b;
                }
                else
                {
                    b = b - a;
                }
            }
            Console.WriteLine(a);
        }
        else
        {
            Console.WriteLine(a + b);
        }
    }
}
